
package msu.ml.data.level2;

import java.io.*;

/**
 * @author Reginald M Mead
 * @version 1.0
 *
 * The Packet class represents a packet
 * of Nexrad Level II data.
 *
 */
public class ElevationDataBlock 
{
   public ElevationDataBlock(Level2InputStream stream)
   {
      name = new char[3];

      if(stream != null)
      {
         try
         {
            type = (char)stream.readByte();
            stream.readBytes(name, 0, 3);
            size = stream.readShort();
            attenuation = stream.readShort();
            calibration = stream.readFloat();
         }
         catch(IOException e)
         {
            System.out.println("ElevationDataBlock Error: " + e.getMessage());
            e.printStackTrace();
         }
      }
   }

   private static String formatString = "\nName: %1$c%2$s\nSize: %3$d\nAttmospheric Attenuation: %4$d\nCalibration: %5$.2f"; 

   public String toString()
   {
      return String.format(ElevationDataBlock.formatString, 
         type, new String(name), size, attenuation, calibration);
   }

   public char type;
   public char [] name;
   public short size;
   public short attenuation;
   public float calibration;
}
